#!/usr/bin/env bash
set -x
set -eu

user={{ansible_user}}

datadir={{mysql_data_dir}}/data
logdir={{mysql_data_dir}}/log
tmpdir={{mysql_data_dir}}/tmp
mkdir -p $datadir $logdir $tmpdir

### init mysql instance
if [ ! -e ${datadir}/ibdata1 ]; then
    {{mysql_home}}/bin/mysqld \
    --defaults-file={{mysql_home}}/etc/my.cnf \
    --initialize-insecure --user=$user
fi
